package components.scenes;

import com.uqbar.vainilla.GameScene;

import components.lifes.LifeCounter;
import components.score.ScoreLabel;

public abstract class ScoreableGameScene extends CollisionablesScene {

	private int quadrantSize = 20;
	private int tableWidth  = 1000;
	private int tableHeight = 1000;

	private double scoreAlign;
	
	private LifeCounter lifeCounter;
	private ScoreLabel scoreGc;
	
	public ScoreableGameScene(double scoreXalign, int initialLifes, int initialScore) {
		super(1000, 1000, 0, 0);
		this.scoreAlign =scoreXalign;
		this.addLifeCounter(initialLifes);
		this.addScoreLabel(initialScore);
	}
	
	
	public int getQuadrantSize() {
		return quadrantSize;
	}


	public void setQuadrantSize(int quadrantSize) {
		this.quadrantSize = quadrantSize;
	}


	public int getTableWidth() {
		return tableWidth;
	}


	public void setTableWidth(int tableWidth) {
		this.tableWidth = tableWidth;
	}


	public int getTableHeight() {
		return tableHeight;
	}


	public void setTableHeight(int tableHeight) {
		this.tableHeight = tableHeight;
	}


	public ScoreLabel getScoreGc() {
		return scoreGc;
	}


	public void setScoreGc(ScoreLabel scoreGc) {
		this.scoreGc = scoreGc;
		
	}	
	public double getScoreAlign() {
		return scoreAlign;
	}


	public void setScoreAlign(double scoreAlign) {
		this.scoreAlign = scoreAlign;
	}


	public LifeCounter getLifeCounter() {
		return lifeCounter;
	}


	public void setLifeCounter(LifeCounter lifeCounter) {
		this.lifeCounter = lifeCounter;
	}



	
	
	private void addLifeCounter(int initialLifes) {
		this.lifeCounter =new LifeCounter(initialLifes);
		this.lifeCounter .setX(this.getScoreAlign());
		this.lifeCounter .setY(100);
		this.lifeCounter.setZ(10);
		this.addComponent(this.lifeCounter );	
	}
	
	private void addScoreLabel(int initialScore) {
		this.scoreGc = new ScoreLabel(initialScore);
		this.scoreGc.setX(this.getScoreAlign());
		this.scoreGc.setY(150);
		this.scoreGc.setZ(10);
		this.addComponent(this.scoreGc);
	}

	public void gameOver() {
		this.getGame().setCurrentScene(this.getGameOverScene(this.getCurrentScore()));
	}
	
	private int getCurrentScore() {
		return this.getScoreGc().getScore();
	}


	public void addScore(int score){
		this.getScoreGc().add(score);
	}

	public void loseLife(){
		this.getLifeCounter().loseLife();
	}

	public abstract GameScene getGameOverScene(int score);


}
